package com.xymtop.api.implement;

import com.xymtop.api.entity.Comment;
import com.xymtop.api.mapper.MyCommentMapper;
import com.xymtop.api.service.MyCommentService;
import com.xymtop.api.utils.Timer;
import com.xymtop.api.vo.CommentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @ClassName : MyCommentImpl
 * @Description : 评论相关的实现
 * @Author : 肖叶茂
 * @Date: 2022/12/1  15:34
 */

@Service
public class MyCommentImpl implements MyCommentService {
    @Autowired
    private MyCommentMapper myCommentMapper;

    @Override
    public Boolean addComment(Comment comment) {
        if(comment.getId()==null){
            comment.setId(Timer.getTimeStamp().toString());
        }

        if(myCommentMapper.addComment(comment)==0){
            return false;
        }else {
            return  true;
        }
    }

    @Override
    public Boolean deleteComment(String id) {
        if(myCommentMapper.deleteComment(id)==0){
            return false;
        }else {
            return  true;
        }
    }

    @Override
    public Comment getComment(String id) {
      return myCommentMapper.getComment(id);
    }

    @Override
    public List<Comment> getCommentByProjectId(String id) {
       return myCommentMapper.getCommentByProjectId(id);
    }

    @Override
    public List<CommentVO> getComments(String projectid) {
        return myCommentMapper.getComments(projectid);
    }

    @Override
    public List<Comment> ins(String key) {
        return myCommentMapper.ins(key);
    }
}
